//
// Created by 215609 on 2024/8/14.
//

#ifndef TSAVPLAYER_AAUDIORENDER_H
#define TSAVPLAYER_AAUDIORENDER_H

#include <aaudio/AAudio.h>

#include "LogUtil.h"
#include "AudioRender.h"

class AAudioRender: public AudioRender {
public:
    AAudioRender();
    virtual ~AAudioRender(){};

    virtual void Init() override;


    void ClearAudioCache() override;
    void RenderAudioFrame(uint8_t *pData, int dataSize) override;
    void UnInit() override;


    aaudio_data_callback_result_t dataCallback(AAudioStream *stream,
                                               void *audioData,
                                               int32_t numFrames);
private:
    AAudioStreamBuilder *builder = nullptr;
    AAudioStream *mAudioStream{nullptr};

    aaudio_format_t mFormat{AAUDIO_FORMAT_PCM_I16};


    void StartRender();
};


#endif //TSAVPLAYER_AAUDIORENDER_H
